# -*- coding: utf-8 -*-
# @Time        :2024/10/22 下午4:37
# @Author      :文刀水寿
# @File        : 02_pymysql_数据插入.py
"""
 @Description :
"""
from pymysql import Connection

# 构建到MYSQL数据库的连接
conn = Connection(
    host='localhost',  # 主机名
    port=3306,  # 端口
    user='root',  # 账户
    password='1028',  # 密码
    autocommit=True  # 设置自动提交
)

cursor = conn.cursor()  # 获得游标对象
conn.select_db("scrapy_使用手册")  # 选择数据库
cursor.execute("insert into test_pymysql values('10001', '周杰伦', '31', '男')")
conn.commit()
conn.close()
